Repository navigation
mm/mempool: fixes and mempool_zallocate() - #22206
Conversation
jerpelea
left a comment
There was a problem hiding this comment.
please split the PR in logical separate PR for separate areas:
memdump
mempool
map
iob
kasan
ubsan
|
694d32d to
52291b0
Compare
|
@jerpelea thanks for the review. I'd prefer to keep this as one PR:
If you would rather not have the build changes here, I can move "nuttx: Adapt for Tasking compiler", "cmake: fix section not take effect" and the fs_heap style fix that goes with them to a separate PR, and retitle this one "mm: fixes and small additions" so it doesn't read as six topics. If that works for you, could you update your review? |
please split the PR |
pool->nalloc need lock to protect Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Initialize semcount before nxsem_get_value() fills it in mempool_release() and mempool_info(), so that it has a value even if the call fails. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
According to MISRA-C2012 8.9, An object should be defined at block scope if its identifier only appears in a single function Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Check before modify, so when check fails, we can still get the original data. Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
… size_t mempool_multiple_init() kept the size of the pool array, a size_t, in the int ret. Use a size_t variable for it. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: makejian <makejian@xiaomi.com>
mempool_zallocate() allocates a block like mempool_allocate() and clears its pool->blocksize bytes, for callers that need a zeroed block. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
nxstyle wants a blank line after the declaration of blk. No functional change. Assisted-by: Kiro:claude-opus-5-5 Signed-off-by: huojianchao <huojianchao@xiaomi.com>
compile error:
In file included from include/nuttx/mm/mempool.h:32,
from include/nuttx/mm/iob.h:36,
from include/nuttx/net/net.h:43,
from include/nuttx/net/netdev_lowerhalf.h:39,
from platform/realtek_ieee80211/realtek_netdev.c:5:
static inline void list_add_tail(struct list_head *newitem, struct list_head *head)
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
249a418
52291b0 to
249a418
Compare
|
@jerpelea Split as requested. This PR now has only the mempool part; the other parts are in their own PRs:
Could you take another look? |
Note: Please adhere to Contributing Guidelines.
Summary
Memory pool fixes and a small addition from Xiaomi Vela.
The first version of this PR also had the other mm changes; as asked in the review, they are now in separate PRs: #22275 (mm_heap: memdump, mm_foreach), #22276 (mm/map), #22277 (mm/iob), #22278 (KASAN), #22279 (UBSAN), #22280 (sim heap), #22281 (CMake section names) and #22282 (Tasking). "mm/iob: add null check for iob2 in iob_clone_partial" and "mm/iob: handle overlapping copyin buffers" went into master with #22204.
mempool_info_task()readspool->nallocunder the pool lock.semcountis initialized beforenxsem_get_value()fills it inmempool_release()andmempool_info().mempool_init()uses becomes a static of that function (MISRA-C 2012 8.9).mempool_remove_queue()checks the next block before it changes the queue head, so the original data is still there when a check fails.size_t.<nuttx/mm/mempool.h>does not include<nuttx/list.h>any more.Impact
mempool_zallocate().<nuttx/mm/mempool.h>no longer includes<nuttx/list.h>; code that got the list API through it has to include<nuttx/list.h>itself.Testing
Host: Ubuntu 22.04 x86_64, GCC 13.4.0 (sim, aarch64-none-elf), Arm GNU Toolchain 13.2.rel1, CMake 3.23 + Ninja 1.10. Base: master 25b649e.
./tools/checkpatch.sh -c -u -m -g HEAD~8..HEADpasses.sim:ostest(KASAN and UBSAN) withCONFIG_MM_HEAP_MEMPOOL_THRESHOLD=32, so that small allocations come from the heap's memory pools: a 320 s run completes one ostest pass with no KASAN/UBSAN report and the same output as master. The same with the default configuration.sim:nshwithCONFIG_MM_BACKTRACE=8 CONFIG_MM_HEAP_MEMPOOL_THRESHOLD=32 CONFIG_MM_HEAP_BIGGEST_COUNT=4:free,echo mempool > /proc/memdumpandecho used > /proc/memdumpwork.Builds: CMake
sim:nsh(options above),sim:ostest,qemu-armv8a:nsh_smp,mps2-an500:nsh; Makesim:nshwith the same options.Not tested: real hardware.